clang-tidy: effective config with warnings-as-errors#537
Merged
Conversation
7ea4ab0 to
ee4b884
Compare
4066a56 to
1a1b045
Compare
ee4b884 to
95520c8
Compare
1a1b045 to
5721443
Compare
Rework .clang-tidy from the stale CLion template into a high-signal config and make the tree clean under it. Config: - enable bugprone-*, clang-analyzer-*, performance-*, portability-* - disable convention-conflicting / high-noise checks (avoid-pragma-once, easily-swappable-parameters, narrowing-conversions, enum-size) - WarningsAsErrors: '*' (clang-analyzer-* kept advisory: its only findings are inside third-party -isystem headers) - drop the removed AnalyzeTemporaryDtors key that made clang-tidy reject the whole file on every run - test/.clang-tidy disables unchecked-optional-access for tests, where gtest assertion macros defeat the dataflow analysis (false positives only) Code fixes (all 148 source findings): - performance-avoid-endl: std::endl -> '\n' - bugprone-implicit-widening-of-multiplication-result: widen before multiply - bugprone-forward-declaration-namespace: drop dead/wrong-namespace fwd decls - bugprone-reserved-identifier: rename __ throwaways; NOLINT wvware's struct - bugprone-empty-catch: NOLINT intentional best-effort catches - bugprone-exception-escape: drop noexcept where functions can throw (string/ path allocation); keep move ops noexcept; wrap CLI main() in try/catch - bugprone-unchecked-optional-access: store re-fetched accessors, key ternaries on the optional, add a decryptor guard; NOLINT genuine invariants - misc: inefficient-string-concatenation, unused-local, unsafe-functions (rewind -> fseek), optional-value-conversion, macro-parentheses, branch-clone Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
5721443 to
e391b0b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Reworks
.clang-tidyfrom the stale CLion template into a high-signal config withWarningsAsErrors, and makes the tree clean under it (all 148 source findings fixed).Based on
pdf-plan-stage1-wrapup(not main) because 8 of the touched files carry unmerged PDF stage-1 changes; retarget to main once that lands.Config
bugprone-*,clang-analyzer-*,performance-*,portability-*.avoid-pragma-once,easily-swappable-parameters,narrowing-conversions,enum-size.WarningsAsErrors: '*', butclang-analyzer-*is kept advisory — its only findings are inside third-party-isystemheaders (cryptopp/httplib/csv) we can't patch.AnalyzeTemporaryDtorskey, which made clang-tidy reject the whole config on every run (the original "noise").test/.clang-tidydisablesunchecked-optional-accessfor tests, where gtest assertion macros defeat the dataflow analysis (false positives only).Notable code changes
bugprone-exception-escape: droppednoexceptfrom functions that can throw (std::string/filesystem::pathallocation), including public API (odr::version,*_to_string,Pathaccessors). Move ops staynoexcept. CLImain()s wrapped in try/catch.unchecked-optional-access: real restructures (store re-fetched accessors, key ternaries on the optional, add a decryptor guard);NOLINTonly for genuine invariants.std::endl→'\n', widen-before-multiply, dead forward-decl removal,rewind→fseek, string-concat via append, etc.Verification
HtmlOutputTests.html_meta/*failures observed locally appear pre-existing on this branch (empty meta output, unrelated to these changes).🤖 Generated with Claude Code